<?php

namespace common\models\patient;

use Yii;

/**
 * This is the model class for table "{{%patient_consumption}}".
 *
 * @property int $id
 * @property int $project_id 项目ID
 * @property string $patient_card_id 诊疗号
 * @property int $clinic_id 诊室ID
 * @property string $consulting_room 诊室【老诊室名】
 * @property string $doctor_name 医生
 * @property int $clinic_time 就诊时间
 * @property float $money 应收金额
 * @property float $reality_money 实收金额（实收金额=实收金额-退款金额[考虑部分退款的情况]）
 * @property float $refund_money 退款金额
 * @property int $trade_type 交易类型： 1：入账 2：退款
 * @property string $remark 备注
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class Consumption extends \common\models\BaseModel
{
    const TRADE_TYPE_BOOKED = 1;// 入账
    const TRADE_TYPE_REFUND = 2;// 退款

    const TRADE_TYPE = [
        self::TRADE_TYPE_BOOKED =>'入账',
        self::TRADE_TYPE_REFUND =>'退款',
    ];

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%patient_consumption}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['project_id', 'clinic_id', 'clinic_time', 'trade_type', 'created_at', 'updated_at'], 'integer'],
            [['money', 'reality_money', 'refund_money'], 'required'],
            [['money', 'reality_money', 'refund_money'], 'number'],
            [['patient_card_id', 'consulting_room'], 'string', 'max' => 50],
            [['doctor_name'], 'string', 'max' => 100],
            [['remark'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'project_id' => '项目ID',
            'patient_card_id' => '诊疗号',
            'clinic_id' => '诊室ID',
            'consulting_room' => '诊室【老诊室名】',
            'doctor_name' => '医生',
            'clinic_time' => '就诊时间',
            'money' => '应收金额',
            'reality_money' => '实收金额（实收金额=实收金额-退款金额[考虑部分退款的情况]）',
            'refund_money' => '退款金额',
            'trade_type' => '交易类型： 1：入账 2：退款',
            'remark' => '备注',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }
}
